import {AppDataSource} from './data-source'
import {User} from './entity/User'

AppDataSource.initialize().then(async () => {
    const userRepository = AppDataSource.getRepository(User)
     const user = new User()
        user.firstName = 'zhang'
        user.lastName = 'san'
        user.age = 18
        user.email = '13123@qq.com'
        user.isActive = true
        await userRepository.save(user)
        const users = await userRepository.find()
        console.log('users', users)
        const founduser = await userRepository.findOne({where: {id:5}})
        console.log('founduser', founduser)
        founduser.age = 100
        await userRepository.save(founduser)
        await userRepository.delete(founduser)
})